﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess.SqlClient;
using Dal;
using Model;
using ApiDAL.Common;
using System.Data;
using System.Data.SqlClient;
namespace Dal
{
    public class ToMenuDAL
    {
        #region 显示今日推荐
        /// <summary>
        /// 显示今日推荐
        /// </summary>
        /// <returns></returns>

        public List<ToMenu> ToMenushow()
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "select * from ToMenu";
            DataSet ds = SqlDataAccess.ExecDataset(sql);
            DataTable dt = ds.Tables[0];
            return DataReaderToObjectHelper.DataTableToList<ToMenu>(dt);

        }
        #endregion

        #region 添加今日推荐
        /// <summary>
        /// 添加今日推荐
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public int AddToMenu(int Toid,string Toname, string Tophoto, string Todescrib,int Toprice)
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "ToMenude";
            sql.CommandType = CommandType.StoredProcedure;
            SqlParameter cc = new SqlParameter();
            cc.Value = Toid;
            cc.ParameterName = "@Toid";
            cc.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc);

            SqlParameter cc1 = new SqlParameter();
            cc1.Value = Toname;
            cc1.ParameterName = "@Toname";
            cc1.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc1);

            SqlParameter cc2 = new SqlParameter();
            cc2.Value = Tophoto;
            cc2.ParameterName = "@Tophoto";
            cc2.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc2);

            SqlParameter cc3 = new SqlParameter();
            cc3.Value = Todescrib;
            cc3.ParameterName = "@Todescrib";
            cc3.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc3);

            SqlParameter cc4 = new SqlParameter();
            cc4.Value = Toprice;
            cc4.ParameterName = "@Toprice";
            cc4.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc4);

            int i = Convert.ToInt32(SqlDataAccess.ExecNonQuery(sql));
            return i;
         
        }
        #endregion

        #region 删除今日推荐
        /// <summary>
        /// 删除今日推荐
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int delToMenu()
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "delete from ToMenu where 1=1";
            return SqlDataAccess.ExecNonQuery(sql);

        }
        #endregion




    }
}
